package com.itheima.ticket03;

public class MyThread extends Thread {
   private static int count =100;
    private static Object obj= new Object();
     @Override
     public void run() {
          while (true){
               //锁对象 必须 唯一
               synchronized (obj) {
                    if(count==0){
                         break;
                    }else {
                         try {
                              Thread.sleep(100);
                         } catch (InterruptedException e) {
                              e.printStackTrace();
                         }
                         count--;
                         System.out.println(Thread.currentThread().getName()+"正在卖票,还剩"+count);
                    }
               }

          }
     }

}
